﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DLL.Entities;
using System.Xml.Serialization;
using System.IO;

namespace RAD
{
    public partial class RAD_Form : Form
    {
        Radar Radquard = new Radar();

        public RAD_Form()
        {
            InitializeComponent();
        }

        private int RandomNumber (int min, int max)
        {
            Random random = new Random();
            return random.Next(min, max);
        }     
           
        private void RAD_Form_Load(object sender, EventArgs e)
        {
            
        }

        private void btnLockOn_Click(object sender, EventArgs e)
        {
            int speed, direction, altitude, distance;
   
                speed = RandomNumber(50 , 2000);
                txtSpeed.Text = speed.ToString();

                direction = RandomNumber(10, 1000);
                txtDirection.Text = direction.ToString();

                altitude = RandomNumber(0, 5000);
                txtAltitude.Text = altitude.ToString();

                distance = RandomNumber(10, 5000);
                txtDistance.Text = altitude.ToString();
            

            //speed = RandomValue(100, 1800);
            //Radquard.Speed = speed;

            //direction = RandomValue(100, 2000);
            //Radquard.Direction = direction;

            //altitude = RandomValue(500, 1000);
            //Radquard.Altitude = altitude;

            //distance = RandomValue(700, 2000);
            //Radquard.Distance = distance;


            //txtSpeed.Text = Convert.ToString(speed);
            //txtDirection.Text = Convert.ToString(direction);
            //txtAltitude.Text = Convert.ToString(altitude);
            //txtDistance.Text = Convert.ToString(distance);


            try
            {
                XmlSerializer serialization = new XmlSerializer(typeof(Radar));
                TextWriter textwriter = new StreamWriter("../../../Radar.xml");
                serialization.Serialize(textwriter, Radquard);
                textwriter.Close();
            }
            catch (Exception ex)
            {
            }

        }

        private void btnScan_Click(object sender, EventArgs e)
        {
            Random randomNumber = new Random();
            int newNumber = randomNumber.Next(4);

            switch (newNumber)
            {
                case 1:
                    rdBtnEagle.Checked = true;
                    break;
                case 2:
                    rdBtnDragon.Checked = true;
                    break;
                case 3:
                    rdBtnFightJet.Checked = true;
                    break;
            }


            
        }

       

       

        
    }
}
